//
//  UIbutton+Extension.swift
//  weibo
//
//  Created by xmg on 15/12/19.
//  Copyright © 2015年 xmg. All rights reserved.
//

import UIKit

extension UIButton
{
    
    convenience init(imageName:String ,backgroundImageName:String)
    {
        self.init()
        
        // 1.设置背景图片
        // 普通状态下
        setBackgroundImage(UIImage(named: backgroundImageName), forState: UIControlState.Normal)
        // 高亮状态下
        setBackgroundImage(UIImage(named: backgroundImageName + "_highlighted"), forState: UIControlState.Highlighted)
        
        // 2.设置按钮图片
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        
        // 3.调整按钮打下
        sizeToFit()
    }
}